#include<stdio.h>
#include<string.h>
#include<stdarg.h>  
#include<stdlib.h>

#include"t2y_main.h" 
#include"resources.h"
#include"constants.h"
#include"server.h"
#include"client.h"

#ifdef UNITTEST
char printed_string[STR_BUF_LEN] = {0};

void print_info(const char *fmt, ...)
{
va_list ap;

memset(printed_string, 0, STR_BUF_LEN);
va_start(ap, fmt);
vsprintf(printed_string, fmt, ap);
va_end(ap);
}
#endif

boolean checkIP(char* ipstr)
{    
	return TRUE;
}      

void print_help(void)
{
	printf("Hi, this is help!\n");
}

#ifdef UNITTEST
void t2y_main(int argc, char* argv[])
#else
void main(int argc, char* argv[])
#endif
{
	if( argc == 1 || (argc == 2 && strcmp( argv[1], STR_DASH_SERVER)==0))
	{
		print_info(STR_SERVER_MODE);
#ifndef UNITTEST
		server_startup();
#endif
	}
	else if(argc == 3 && strcmp( argv[1], STR_DASH_CONNECT)==0)
	{ 
		print_info("%s%s\n", STR_CLIENT_MODE, argv[2]);
#ifndef UNITTEST
		client_startup(argv[2]);
#endif 
	}
	else if(argc == 2 
		    && (strcmp( argv[1], STR_DASH_QUESTION_MARK)==0
		          || strcmp( argv[1], STR_DASH_H)==0
		          || strcmp( argv[1], STR_DASH_HELP)==0))
	{ 
		print_help();
	}
	else
	{
		printf(STR_INVALID_PARAM);
		print_help();	
	}

}

























